import { post ,get} from '@/utils/http/request';
// 定义登录表单数据类型
interface LoginRequire {
  username: string;
  password: string;
  [key: string]: unknown; // 添加索引签名以兼容 Record<string, unknown>
}

// 定义登录响应数据类型
interface LoginResponse {
  token: string;
  userInfo: Record<string, unknown>;
  [key: string]: unknown;
}

interface Response{
  code: number;
}

export interface MenuItem {
  key: string;
  label: string;
  icon: string;
  children?: MenuItem[];
}


// 登录API
export function loginApi(data: LoginRequire) {
  return post<LoginResponse>('/api/login', data);
}

export function logoutApi() {
  return get<Response>('/api/logout')
}

export function getMenuApi() {
  return get<MenuItem[]>("/api/menu")
}